package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Employee;

import java.time.LocalDate;
import java.util.List;

import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 插入单个用户信息
     * @param employee
     * @return
     */
    @AutoFill(OperationType.INSERT)
    int insert(@Param("employee") Employee employee);

    /**
     * 查询分页用户用户信息
     * @param username
     * @return List
     */
    List<Employee> selectEmployeePage(@Param("username") String username);
    /**
     * 根据id查询用户信息
     * @param id
     * @return  Employee
     */
    @Select("select * from employee where id = #{id}")
    Employee selectEmployeeOneById(long id);

    /**
     * 修改员工状态
     * @param employee
     * @return
     */
    @AutoFill(OperationType.UPDATE)
    @Update("update employee set status=#{employee.status},update_time=#{employee.updateTime},update_user=#{employee.updateUser} where id=#{employee.id}")
    int changeEmployeeStatus(@Param("employee") Employee employee);

    /**
     * 更新员工信息
     * @param emp
     * @return
     */
    @AutoFill(OperationType.UPDATE)
    int update(Employee emp);

}
